import { createRouter, createWebHistory } from 'vue-router'
import  routes  from './routes'
import { get_token } from '@/utils/auth'
import { check_login } from '@/api/login'
const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
 routes
})
router.beforeEach(async (to, from, next) => {
  if (!to.meta.not_check) {
    if (!get_token()) {
      next('login');
      return;
    }
    const res=await check_login();
    console.log(res,";;;;;");
  }
  next();
});
export default router
